<template>
  <div class="cart-item">
    <div class="img">
      <img :src="url" alt="">
    </div>
    <div class="desc">
      <h3>{{title}}</h3>
      <div class="couter">
        <span
          @click="changeCount({type: 'reduce', id})"
        class="reduce"
        >-</span><span
          class="count"
        >{{count}}</span><span
          class="add"
          @click="changeCount({type: 'add', id})"
        >+</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'cart-item',
  props: {
    id: Number,
    title: String,
    url: String,
    count: Number,
    changeCount: Function,
  },
};
</script>

<style lang="scss" scoped>
.cart-item {
  display: flex;
  height: 150px;
  padding: 15px;
}
.img {
  height: 150px;
  margin-right: 15px;
  img {
    height: 100%;
  }
}
.desc {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.couter {
  width: 90px;
  border: 1px solid #dedede;
  border-radius: 5px;

  span {
    width: 30px;
    display: inline-block;
    text-align: center;
    color: #666;

    &.count {
      box-sizing: border-box;
      border-style: solid;
      border-color: #dedede;
      border-width: 0 1px;
    }
  }
}
</style>
